<!DOCTYPE HTML>
<html>

<head>
	<meta charset="utf-8">
	<meta name="viewport"
		content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
	<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
	<title>消息</title>
	<link rel="stylesheet" type="text/css" href="../../css/api.css" />
	<style>
		body {
			padding-bottom: 30px;
		}

		.one_style {
			height: 160px;
			top: 0;
			left: 0;
			right: 0;
			position: fixed;
			padding: 0 15px;
			background-image: linear-gradient(45deg,
					#ff3a24 0%,
					#ff5340 100%);
		}

		.header {
			color: #ffffff;
			width: 100%;
			height: 44px;
			line-height: 44px;
			text-align: center;
			position: relative;
			font-size: 16px;
			display: flex;
			align-items: center;
			justify-content: center;
		}

		.header img:first-child {
			width: 22px;
			height: 22px;
			position: absolute;
			left: 0;
		}

		.one_style .tips {
			margin: 10px 0;
			width: 100%;
			height: 40px;
			background-color: #ffffff;
			display: flex;
			align-items: center;
			padding: 0 15px;
			box-sizing: border-box;
			justify-content: space-between;
			border-radius: 10px;
			color: #000000;
			font-size: 12px;
		}

		.one_style .tips .tips_left {
			display: flex;
			align-items: center;
		}

		.one_style .tips .tips_left img {
			width: 17px;
			height: 15px;
			margin-right: 5px;
		}

		.one_style .tips .tips_right {
			display: flex;
			align-items: center;
		}

		.one_style .tips .tips_right img {
			widows: 22px;
			height: 22px;
			margin-left: 10px;
		}

		.one_style .tips .tips_right .btn {
			padding: 2px 8px;
			background-image: linear-gradient(45deg,
					#ff3a24 0%,
					#ff5340 100%);
			color: #ffffff;
			border-radius: 15px;
			font-weight: bold;
		}

		.one_style .btns {
			padding: 10px;
			border-radius: 15px;
			background: #ffffff;
			display: flex;
			align-items: center;
			flex-wrap: nowrap;
			justify-content: space-between
		}

		.btns div img {
			width: 60px;
			height: 60px;
		}

		.btns div .earn {
			font-size: 14px;
			color: #333;
		}

		.btns div {
			flex: 1;
			display: flex;
			flex-direction: column;
			align-items: center;
		}

		.content {
			width: 100%;
			box-sizing: border-box;
			padding: 0 15px;
		}

		.content li {
			width: 100%;
			border-radius: 10px;
			overflow: hidden;
			background-color: #ffffff;
			box-sizing: border-box;
			margin-bottom: 15px;
		}

		.content li img {
			width: 100%;
			height: 150px;
			object-fit: cover;
		}

		.content li .title {
			font-size: 16px;
			line-height: 16px;
			margin: 15px 0 7.5px;
			color: #000;
			width: 280px;
			overflow: hidden;
			white-space: nowrap;
			text-overflow: ellipsis;
			padding: 0 15px;
			box-sizing: border-box;
		}

		.details {
			width: 100%;
			padding: 0 15px;
			box-sizing: border-box;
			overflow: hidden;
			text-overflow: ellipsis;
			display: -webkit-box;
			-webkit-line-clamp: 2;
			-webkit-box-orient: vertical;
			font-size: 13px;
			color: #666;
		}

		.times {
			width: 100%;
			padding: 0 15px;
			box-sizing: border-box;
			font-size: 12px;
			color: #999;
			margin-bottom: 15px;
			margin-top: 10px;
		}
	</style>
</head>

<body>
	<div class="one_style">
		<div class="header">
			<img src="../../image/icon_return_white.png" alt="" onclick="back()">
			消息
			<!-- <img onclick="message_setting()" src="../../image/message_icon_messagesettings.png" alt=""> -->
		</div>
		<!-- <div class="tips">
			<div class="tips_left">
				<img src="../../image/message_icon_notice.png" alt="">
				打开消息通知，及时收到消息~
			</div>
			<div class="tips_right">
				<div class="btn" onclick="message_setting()">去开启</div>
				<img src="../../image/message_icon_close.png" alt="" onclick="closeDiv()">
			</div>
		</div> -->
		<div class="btns">
			<div onclick="message_profit()">
				<img src="../../image/message_icon_income.png" alt="">
				<span class="earn">收益消息</span>
			</div>
			<div onclick="message_fans()">
				<img src="../../image/message_icon_fans.png" alt="">
				<span class="earn">粉丝消息</span>
			</div>
			<div onclick="message_system()">
				<img src="../../image/message_icon_system.png" alt="">
				<span class="earn">系统消息</span>
			</div>
			<div onclick="message_feedBack()">
				<img src="../../image/message_icon_feedback.png" alt="">
				<span class="earn">反馈消息</span>
			</div>
		</div>
	</div>
	<div class="content">

	</div>
</body>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript">
	let one_styleH;
	let page = 1;
	let article = []
	apiready = function () {
		resume("message_index");

		one_styleH = $api.fixStatusBar($api.dom('.one_style'));
		// $api.dom('.two_style').style.paddingTop = one_styleH + 55 + 'px';
		$api.dom('.content').style.paddingTop = one_styleH + 'px';
		$api.dom('.one_style').style.height = 100 + 'px';
		getArticle(0)
	}
	function getArticle(type) {
		$api.ajax({
			url: 'api/article/list',
			method: 'get',
			data: {
				values: {
					type: type,
					page: page,
				}
			},
			page: page,
			timeOutHtml: $api.dom('.content')
		}, function (ret) {

			article = article.concat(ret.data.list);
			ret.data.list.forEach(item => {
				let html = `<li class="list" onclick="open_details(` + item.id + `)">`
					+ (item.pic_url ? `<img src="` + $api.baseUrl + item.pic_url + `" alt="" onerror="showDefaultImg(this)">` : "")
					+ `<div class="title">` + item.title + `</div>
					<div class="details">`+ item.content + `</div>
					<div class="times">`+ getLocalTime(item.publish_time) + `</div>
				</li>`
				$api.append($api.dom(".content"), html);
			})
			api.refreshHeaderLoadDone();
			api.parseTapmode();
		});
	}

	function addEvent() {
		api.addEventListener({
			name: 'scrolltobottom',
			extra: {
				threshold: 1000,
			},
		}, function (ret, err) {
			page++;
			getArticle()
			api.removeEventListener({
				name: 'scrolltobottom'
			});
			setTimeout(function () {
				addEvent()
			}, 1000)
		});
	}

	function open_details(id) {
		let url = article[article.findIndex(item => {
			return item.id == id
		})].url
		if (url) {
			api.openTabLayout({
				name: 'Url',
				url: '../Url.html',
				useWKWebView: true,
				bgColor: '#fff',
				pageParam: { url: url }
			});
		} else {
			api.openTabLayout({
				name: 'notice_details',
				url: '../me/notice_details.html',
				useWKWebView: true,
				bgColor: '#fff',
				pageParam: {
					id: id
				}
			});
		}
	}

	function closeDiv() {
		$api.dom(".tips").style.display = "none";
		$api.dom('.one_style').style.height = 100 + 'px';
		$api.dom('.content').style.paddingTop = one_styleH + 15 + 'px'
	}

	//消息设置
	function message_setting() {
		if (getToken()) {
			api.openTabLayout({
				name: 'message_setting',
				url: 'message_setting.html',
				useWKWebView: true,
				bgColor: '#fff',
			})
		}
	}
	//反馈消息
	function message_feedBack() {
		if (getToken()) {
			api.openTabLayout({
				name: 'message_feedBack',
				url: 'message_feedBack.html',
				useWKWebView: true,
				bgColor: '#fff',
			})
		}
	}
	//系统消息
	function message_system() {
		if (getToken()) {
			api.openTabLayout({
				name: 'message_system',
				url: 'message_system.html',
				useWKWebView: true,
				bgColor: '#fff',

			})
		}
	}
	//粉丝消息
	function message_fans() {
		if (getToken()) {
			api.openTabLayout({
				name: 'message_fans',
				url: 'message_fans.html',
				useWKWebView: true,
				bgColor: '#fff',
			})
		}
	}
	//收益消息
	function message_profit() {
		if (getToken()) {
			api.openTabLayout({
				name: 'message_profit',
				url: 'message_profit.html',
				useWKWebView: true,
				bgColor: '#fff',
			})
		}
	}

	function back() {
		api.closeWin({
		});
	}
</script>

</html>
